package com.vm.action.phoneSubInfo;

import java.sql.Timestamp;
import java.util.Date;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.Preparable;
import com.vm.action.ActionSuper;
import com.vm.common.Page;
import com.vm.dao.phoneSubInfo.PhoneSubInfoDao;
import com.vm.entity.PhoneSubInfo;
import com.vm.entity.SystemUser;
import com.vm.log4j.CustomizeLog4j;

public class PhoneSubInfoAction extends ActionSuper implements Preparable{
	private static Logger log = CustomizeLog4j.getLogger(PhoneSubInfoAction.class);
	private Page<PhoneSubInfo> page;
	private PhoneSubInfo phoneSubInfo;
	private PhoneSubInfoDao phoneSubInfoDao;
	private String pageLinkList;



	
	@Override
	public void prepare() throws Exception {
		// TODO Auto-generated method stub
		
	}
	
	
	public String list(){
		this.page = this.phoneSubInfoDao.page(this.PAGE_ROW_SIZE, super.getPageNumber());
		this.pageLinkList =super.getSplitPageLink("/phoneSubInfo/phoneSubInfoAction_list.do?", this.page);
		return SUCCESS;
	}
	
	public String add() throws Exception {
		return SUCCESS;
	}

	public String save() throws Exception {
		String[] msgArg = new String[] { "phoneSubInfoAction_list.do"};
		String msg = null;
		try {
			SystemUser su = new SystemUser();
			su.setSuId(1);
			su.setSuName("admin");
			phoneSubInfo.setSystemUser(su);
			phoneSubInfo.setXfSj(new Timestamp(new Date().getTime()));
			phoneSubInfoDao.save(phoneSubInfo);
			msg = super.getResourceMessage("insert_phoneSubInfo_success", msgArg);
		} catch (Exception e) {
			log.error("PhoneSubInfoAction save phoneSubInfo error  ", e);
			msg = super.getResourceMessage("insert_phoneSubInfo_err", msgArg);
		}
		super.setShowMessage(msg);
		return super.SHOW_MESSAGE_RESULT;
	}

	public String edit(){
		phoneSubInfo = phoneSubInfoDao.findById(this.phoneSubInfo.getXfId());
		return SUCCESS;
	}

	public String update() throws Exception {
		String[] msgArg = new String[] { "phoneSubInfoAction_list.do"};
		String msg = null;
		try {
			SystemUser su = phoneSubInfo.getSystemUser();
			su.setSuId(2);
			su.setSuName("admins");
			phoneSubInfo.setSystemUser(su);
			phoneSubInfo.setXfSj(new Timestamp(new Date().getTime()));
			phoneSubInfoDao.update(phoneSubInfo);
			msg = super.getResourceMessage("update_phoneSubInfo_success", msgArg);
		} catch (Exception e) {
			log.error("PhoneSubInfoAction save PhoneSubInfo error  ", e);
			msg = super.getResourceMessage("update_phoneSubInfo_err", msgArg);
		}
		super.setShowMessage(msg);
		return super.SHOW_MESSAGE_RESULT;

	}

	public String delete() {
		String[] msgArg = new String[] { "phoneSubInfoAction_list.do"};
		String msg = null;
		try {
			phoneSubInfoDao.deleteById(this.phoneSubInfo.getXfId());
			msg = super.getResourceMessage("delete_phoneSubInfo_success", msgArg);
		} catch (Exception e) {
			log.error("PhoneSubInfoAction delete PhoneSubInfo error  ", e);
			msg = super.getResourceMessage("delete_phoneSubInfo_err", msgArg);
		}
		super.setShowMessage(msg);
		return super.SHOW_MESSAGE_RESULT;
	}
   

	public Page<PhoneSubInfo> getPage() {
		return page;
	}


	public void setPage(Page<PhoneSubInfo> page) {
		this.page = page;
	}


	public PhoneSubInfo getPhoneSubInfo() {
		return phoneSubInfo;
	}


	public void setPhoneSubInfo(PhoneSubInfo phoneSubInfo) {
		this.phoneSubInfo = phoneSubInfo;
	}


	

	public String getPageLinkList() {
		return pageLinkList;
	}


	public void setPageLinkList(String pageLinkList) {
		this.pageLinkList = pageLinkList;
	}
    
	public PhoneSubInfoDao getPhoneSubInfoDao() {
		return phoneSubInfoDao;
	}


	public void setPhoneSubInfoDao(PhoneSubInfoDao phoneSubInfoDao) {
		this.phoneSubInfoDao = phoneSubInfoDao;
	}



}
